<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>权限管理</title>
	<link rel="stylesheet" href="../css/common2.css">
	<style scoped>
		.hut_but_tz {
			display: inline-block;
			height: 38px;
			width: 108px;
			line-height: 38px;
			padding: 0 18px;
			background: url(../image/enter.png) no-repeat center center;
			color: #fff;
			white-space: nowrap;
			text-align: center;
			font-size: 14px;
			border: none;
			border-radius: 2px;
			cursor: pointer;
		}

		.search_box {
			display: flex;
			align-items: center;
		}

		.search_left {
			display: flex;
			align-items: center;
			margin-right: 30px;
		}

		.select_s {
			width: 100px;
			height: 35px;
			border: none;
			margin-right: 5px;
		}

		.search_name {
			height: 35px;
			max-width: 135px;
			padding: 0 5px;
			margin-right: 5px;
		}

		.table {
			width: 99%;
		}

		.four {
			width: auto;
		}
	</style>
</head>

<body class="main-body">
	<div id="vue-root" style="margin-top:50px;">
		<div class="search_box">
			<div class="search_left">
				<select v-model="search.type" class="select_s">
					<option :value="undefined">全部</option>
					<option :value="2">单校</option>
					<option :value="1">代理商</option>
				</select>
				<input class="search_name" placeholder="请输入员工姓名/手机号" v-model="search.nameOrPhone" @input="input">
				<img src="../image/search.png" height="35" width="35" class="search_img" @click="getData0">
			</div>
			<div class="add"  v-if="able.add">
				<a href="staffManagement_item.html" style="color: white">添加员工账号</a>
			</div>
			<!-- <div class="refresh" onclick="location.reload()" style="display: inline-block;">刷新</div> -->
		</div>
		<div class="table ">
			<table class="table_top">
				<thead>
					<tr>
						<th class="two">序号</th>
						<th>类型</th>
						<th class="two">员工姓名</th>
						<th class="two">权限组</th>
						<th class="two">归属校区</th>
						<th class="two">状态</th>
						<th class="two">是否启用</th>
						<th class="two">合同周期</th>
						<th class="two">离职时间</th>
						<th class="three">编辑/删除</th>
					</tr>
				</thead>
				<tbody id="list">
					<tr v-for="(item,index) in list" :key="item.id">
						<td style="width: 100px"><span v-text="index+1"></span></td>
						<td><span v-text="item.type==1?'代理商':'单校'"></td>
						<td class="four" v-text="item.name"></td>
						<td class="four" v-text="item.authName"></td>
						<td class="four" v-text="filtrateName(item)||'代理商'"></td>
						<td class="four" v-text="item.status==0?'离职':'在职'"></td>
						<td class="four">
							<div class="layui-input-block labels">
								<label class="checkbox-inline i-checks">
									<input type="radio" v-model="item.enable" value="true" :name="'sw'+index" @input="enableChange(item,'true')" :disabled="item.status ==0">
									<i></i> 启用
								</label>
								<label class="checkbox-inline i-checks">
									<input type="radio" v-model="item.enable" value="false" :name="'sw'+index" @input="enableChange(item,'false')" :disabled="item.status ==0">
									<i></i> 停用
								</label>
							</div>
						</td>
						<td class="four">
							{{item.startTime+'~'+item.endTime}}
						</td>
						<td class="four">
							{{item.turnoverTime||''}}
						</td>
						<td class="three" style="width: 100px">
							<div class="option">
								<div class="edit-icon option-icon" v-if="able.edit">
									<a :href="'staffManagement_item.html?id='+item.id+'&type='+item.type"
										style="position: absolute; left: 20%; top: 30%;">
										<img class="img" src="../image/edit.png" height="20" width="20"
											onmouseover="this.src='../image/edit_light.png'"
											onmouseout="this.src='../image/edit.png'" />
									</a>
								</div>
								<div class="delete-icon option-icon" v-if="able.del" @click="del([item.id])"
									style="right: 20%; top:30%;position: absolute;">
									<img class="img" src="../image/delete.png" height="20" width="20"
										onmouseover="this.src='../image/delete_light.png'"
										onmouseout="this.src='../image/delete.png'" />
								</div>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>

		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum&#45;&#45;">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>

		</ul>
		<div style="float: right;margin-bottom: 20px;">
			总共{{total}}条记录
			<select class="ui-select init" style="height:32px" v-model="pageSize">
				<option :value="10">每页10条</option>
				<option :value="30">每页30条</option>
				<option :value="100">每页100条</option>
			</select>
		</div>

	</div>
	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/list.js"></script>
	<script src="/js/auth_util.js"></script>

	<script>

		new Vue(merge({
			data: {
				schoolListss: [],
				urls: {
					list: '/pc/staffUser/list/' + top_params().id,
					del: '/pc/staffUser/del'
				}
			},
			created:function() {
				abled('memberManage',this);
				this.getData();
				this.getschool();
			},
			methods: {
				input() {
					if (this.search.name == '') {
						this.search = {}
					}
				},
				//获取学校
				getschool: function () {
					axios.get('/pc/school/all/' + top_params().id).then(function (res) {
						this.schoolListss = res.data
					}.bind(this));
				},
				filtrateName: function (item) {
					var obj = {}
					for (let i = 0; i < this.schoolListss.length; i++) {
						if (this.schoolListss[i].id == item.schoolId) {
							obj = this.schoolListss[i]
						}
					}
					if(item.type==1) return null;
					return obj.name;
				},
				enableChange:function(item,b){
					var obj={}
					obj.enable=b
					obj.id=item.id

					axios.put('/pc/staffUser', obj).then(function (res) {
                        alert("修改成功");
						this.getData();
						this.getschool()
                    }.bind(this));
				}
			}
		}));
	</script>


</body>

</html>